extends Area2D

@export var speed = 1200.0
@export var attack_params : Dictionary = {
	damage = 10.0
}
@onready var destory_timer : Timer = $DestoryTimer
var aim_target : Node2D

func _ready():
	destory_timer.timeout.connect(_on_destory_event)
	body_entered.connect(_on_body_entered_event)
	pass

func _physics_process(delta):
	if aim_target :
		global_position += ((aim_target.global_position - Vector2(0,50)) - global_position).normalized() * delta * speed

func _emit(pos :Vector2 ,target : Node2D) :
	global_position = pos
	aim_target = target

func _on_body_entered_event(_body : Node2D) :
	_body._hurt(attack_params)
	_on_destory_event()

func _on_destory_event() :
	queue_free()
